package com.example.demo;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableTransactionManagement
@EnableAutoConfiguration(exclude = { //
		DataSourceTransactionManagerAutoConfiguration.class, //
		HibernateJpaAutoConfiguration.class })
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@RestController
	public class RC {

		@Autowired
		ServiceTest service;

		@GetMapping("/test")
		public String get() {
			ExecutorService es = Executors.newFixedThreadPool(2);
			es.submit(new Callable<String>() {

				@Override
				public String call() throws Exception {
					String a;
					System.out.println(a = service.m1());
					return a;
				}
			});

			es.submit(new Callable<String>() {

				@Override
				public String call() throws Exception {
					String a;
					System.out.println(a = service.m2());
					return a;
				}
			});

			return "done";
		}
	}

}
